package Product;
import basic.BurglarProofDoor;
import Part.Lock;
public class DoorLock implements Lock{
    private int judgement = -1;
    /**
     * 锁头功能组
     */

    // 用户前台-防盗功能
    public int checkCode(String _code) {
        if (_code.equals(BurglarProofDoor.returnCode())) {
            return 1;
        } else {
            return -1;
        }
    }

    // 上锁和解锁的方法
    public void unlock(String _code) {
        judgement = this.checkCode(_code);
        if (judgement == 1) {
            System.out.println("Access Granted");
            new BurglarProofDoor().open();
        } else
            return;
    }
    public void lock(String _code) {
        judgement = this.checkCode(_code);
        if (judgement == -1) {
            System.out.println("Error");
            new BurglarProofDoor().close();
        } else
            return;
    }
}